{% extends "sentry/bases/admin.html" %}

{% load i18n %}
{% load sentry_helpers %}
{% load sentry_plugins %}

{% block title %}{{ tag.value }} | {{ block.super }}{% endblock %}

{% block bodyclass %} with-sidebar{% endblock %}

{% block sidebar %}
    <h6>User Details</h6>
    <dl>
        <dt>Email:</dt>
        <dd>{% if tag.data.email %}{{ tag.data.email }}{% else %}&mdash;{% endif %}</dd>
        <dt>First Seen:</dt>
        <dd>{{ tag.first_seen|timesince }}</dd>
        <dt>Last Seen:</dt>
        <dd>{{ tag.last_seen|timesince }}</dd>
        <dt>Number of Events:</dt>
        <dd>{{ tag.times_seen|small_count }}</dd>
    </dl>
    {% if tag.data.data %}
        <h6>Metadata</h6>
        <dl>
            {% for key, value in tag.data.data.iteritems %}
                <dt>{{ key|titlize }}</dt>
                <dd>{{ value }}</dd>
            {% endfor %}
        </dl>
    {% endif %}
{% endblock %}

{% block main %}
    {% paginator event_list from request as event_list per_page EVENTS_PER_PAGE %}

    <div class="btn-toolbar">
        <div class="pull-left">
            <h2 style="line-height:1;">{{ tag.value }}{% if tag.data.email %} <small>{{ tag.data.email }}</small>{% endif %}</h2>
        </div>
        <div class="btn-group pull-right">
            <a class="btn prev{% if not event_list.paginator.has_previous %} disabled{% else %}" href="?p={{ event_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
            <a class="btn next{% if not event_list.paginator.has_next %} disabled{% else %}" href="?p={{ event_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
        </div>
    </div>

    <div id="event_list"></div>

    <script>
    new app.GroupListView({
        className: 'group-list',
        members: {{ event_list.paginator.objects|to_json:request|safe }},
        id: "event_list"
    });
    </script>

    <div class="btn-toolbar">
        <div class="btn-group pull-right">
            <a class="btn prev{% if not event_list.paginator.has_previous %} disabled{% else %}" href="?p={{ event_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
            <a class="btn next{% if not event_list.paginator.has_next %} disabled{% else %}" href="?p={{ event_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
        </div>
    </div>
{% endblock %}
